package cn.livingCloud.dto;

import org.hyperic.sigar.FileSystem;
import org.hyperic.sigar.FileSystemUsage;
import org.hyperic.sigar.Sigar;

/**
 * Created by 唐旭 on 2016/7/5.
 */
public class FileSystemDto {
    private String devName;
    private String dirName;
    private long flags;
    private String sysTypeName;
    private String typeName;
    private int type;

    //文件系统总大小KB
    private long total;
    //文件系统剩余大小KB
    private long free;
    //文件系统可用大小KB
    private long avail;
    //文件系统已经使用量KB
    private long used;
    //文件系统资源的利用率100%
    private double usePercent;

    private long diskReads;
    private long diskWrites;

    public FileSystemDto() {
    }

    public FileSystemDto(FileSystem fs, Sigar sigar) {
        try {
            devName = fs.getDevName();
            this.dirName = fs.getDirName();
            this.flags = fs.getFlags();
            this.sysTypeName = fs.getSysTypeName();
            this.typeName = fs.getTypeName();
            this.type = fs.getType();
            FileSystemUsage usage = sigar.getFileSystemUsage(fs.getDirName());
            total = usage.getTotal();
            free = usage.getFree();
            avail = usage.getAvail();
            used = usage.getUsed();
            usePercent = usage.getUsePercent() * 100D;

        } catch (Exception e) {
            //ignore
        }

    }

    public long getAvail() {
        return avail;
    }

    public FileSystemDto setAvail(long avail) {
        this.avail = avail;
        return this;
    }

    public String getDevName() {
        return devName;
    }

    public FileSystemDto setDevName(String devName) {
        this.devName = devName;
        return this;
    }

    public String getDirName() {
        return dirName;
    }

    public FileSystemDto setDirName(String dirName) {
        this.dirName = dirName;
        return this;
    }

    public long getDiskReads() {
        return diskReads;
    }

    public FileSystemDto setDiskReads(long diskReads) {
        this.diskReads = diskReads;
        return this;
    }

    public long getDiskWrites() {
        return diskWrites;
    }

    public FileSystemDto setDiskWrites(long diskWrites) {
        this.diskWrites = diskWrites;
        return this;
    }

    public long getFlags() {
        return flags;
    }

    public FileSystemDto setFlags(long flags) {
        this.flags = flags;
        return this;
    }

    public long getFree() {
        return free;
    }

    public FileSystemDto setFree(long free) {
        this.free = free;
        return this;
    }

    public String getSysTypeName() {
        return sysTypeName;
    }

    public FileSystemDto setSysTypeName(String sysTypeName) {
        this.sysTypeName = sysTypeName;
        return this;
    }

    public long getTotal() {
        return total;
    }

    public FileSystemDto setTotal(long total) {
        this.total = total;
        return this;
    }

    public int getType() {
        return type;
    }

    public FileSystemDto setType(int type) {
        this.type = type;
        return this;
    }

    public String getTypeName() {
        return typeName;
    }

    public FileSystemDto setTypeName(String typeName) {
        this.typeName = typeName;
        return this;
    }

    public long getUsed() {
        return used;
    }

    public FileSystemDto setUsed(long used) {
        this.used = used;
        return this;
    }

    public double getUsePercent() {
        return usePercent;
    }

    public FileSystemDto setUsePercent(double usePercent) {
        this.usePercent = usePercent;
        return this;
    }
}
